#include <queue>
#include <iostream>

using namespace std;

int main()
{
	queue<int> q;
	int Q; cin >> Q;
	while(Q--)
	{
		int op; cin >> op;
		if(op == 1)
		{
			int x; cin >> x;
			q.push(x);
		}
		else
		{
			int x = q.front(); q.pop();
			cout << x << endl;
		}
	}
	return 0;
}
